<template>
	<view>
		<view style="margin: 10px;">
			<uv-button type="primary" text="请求：Get" @click="getData"></uv-button>
		</view>
		<view style="margin: 10px;">
			<uv-button type="success" text="请求：Post" @click="postData"></uv-button>
		</view>
		<view style="margin: 10px;">
			<uv-button type="error" text="请求：404" @click="getError"></uv-button>
		</view>
		异步数据：{{title}}
		
	</view>
</template>

<script>
	import { getDemoData,postDemoData,getDemoData404 } from '@/common/api.js';
	export default {
		data() {
			return {
				title:''
			}
		},
		onLoad(){
			this.getData()
		},
		methods: {
			async getData(){
				const data = await getDemoData()
				console.log(data)
				if(data.code == 0){
					this.title = data.data
				}
			},
			async postData(){
				const params = {
					id:'123'
				}
				const data = await postDemoData(params)
				console.log(data)
				if(data.code == 0){
					this.title = data.data
				}
			},
			async getError(){
				const data = await getDemoData404()
				console.log(data)
				if(data.code == 0){
					this.title = data.data
				}
			}
		}
	}
</script>

<style>

</style>
